package com.itheima.dao.impl;

import com.itheima.dao.StudentDao;
import com.itheima.domain.Student;

import java.util.ArrayList;

public class StudentDaoImpl implements StudentDao {
    private static ArrayList<Student> arrStus = new ArrayList<>();

    static {
        arrStus.add(new Student("001","张三","20","Java","123"));
        arrStus.add(new Student("002","李四","25","JavaWeb","456"));
    }

    //添加
    @Override
    public boolean addStudent(Student stu) {
        arrStus.add(stu);
        return true;
    }

    //查看
    @Override
    public ArrayList<Student> findAllStudents() {
        return arrStus;
    }

    //判断账号是否存在
    @Override
    public boolean judge(String id) {
        for (int i = 0; i < arrStus.size(); i++) {
            if (arrStus.get(i).getId().equals(id)){
                return true;
            }
        }
        return false;
    }
}
